<template>
	<view class="content">
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="修改签名" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<textarea class="shubox" maxlength="30" placeholder="请输入新签名" v-model="userInfo.signature_des"></textarea>
		
		
		
		<view class="ti" @click="saveUser()">
			保存
		</view>
		
		<view class="wenan">
			请输入30字以内，内容请勿违反平台相关规定
		</view>
		
	</view>
</template>
<script>
	export default { 
		data() {
			return {
				userInfo: this.$db.get('userInfo'),
			}
		},
		onShow() {
			// this.getUserInfo()
		},
		onLoad() {

		},
		methods: {
			getUserInfo() {
				this.$api.default.request('user/userInfo').then((res) => {
					if (res.code) {
						this.userInfo = res.user
						this.index = res.user.sex?res.user.sex:0
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			saveUser() { 
				var prams = {
					'signature_des': this.userInfo.signature_des
				}
				this.$api.default.request('user/saveUser', prams).then((res) => {
					if (res.code == 1) {
						this.$db.set('userInfo',res.user)
						this.userInfo = res.user
						this.$common.successToShow(res.msg,()=>{
							uni.navigateBack()
						})
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(242, 245, 242, 1);
	}
	.content {
		padding-top: 20rpx;
		.shubox{
			padding: 40rpx 68rpx;
			background-color: #ffffff;
			color: #3d3d3d;
			width: 616rpx;
			font-size: 28rpx;
			margin-bottom: 20rpx;
			height: 280rpx;
		}
		.ti{
			width: 630rpx;
			height: 86rpx;
			border-radius: 8px;
			line-height: 86rpx;
			margin: 0 auto;
			opacity: 1;
			background: #45C4B0;
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			letter-spacing: 0em;
			color: #FFFFFF;
		}
		.wenan{
			color: #999;
			font-size: 24rpx;
			text-align: center;
			width: 100%;
			margin-top: 30px;
		}
	}
</style>